﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Runtime;
using System.Data;

namespace OpenSource.Controls
{
    public class InputFormCellField : TableCell, IDataItemContainer, INamingContainer
    {
        private InputFormCell _containingField;

        private int _cellIndex;
        private int _dataItemIndex;
        private object _dataItem;



        public virtual object DataItem
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get
            {
                return this._dataItem;
            }
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            set
            {
                this._dataItem = value;
            }
        }

        public virtual int DataItemIndex
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get
            {
                return this._dataItemIndex;
            }
        }

        public virtual int CellIndex
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get
            {
                return this._cellIndex;
            }
        }

        public InputFormCellField(InputFormCell containingField, int cellIndex, int dataItemIndex)
        {
            this._cellIndex = cellIndex;
            this._dataItemIndex = dataItemIndex;
            this._containingField = containingField;
        }


        //protected InputFormCellField(HtmlTextWriterTag tagKey, InputFormCell containingField)
        //    : base(tagKey)
        //{
        //    _containingField = containingField;
        //}


        public InputFormCell ContainingField
        {
            get { return _containingField; }
        }

        protected override bool OnBubbleEvent(object source, EventArgs e)
        {
            if (!(e is CommandEventArgs))
                return false;
            this.RaiseBubbleEvent((object)this, e);// (EventArgs)new GridViewCommandEventArgs(this, source, (CommandEventArgs)e));
            return true;
        }


        object IDataItemContainer.DataItem
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get
            {
                return GetSource(); //return this.DataItem;
            }
        }

        int IDataItemContainer.DataItemIndex
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get
            {
                return this.DataItemIndex;
            }
        }

        int IDataItemContainer.DisplayIndex
        {
            [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
            get
            {
                return this.CellIndex;
            }
        }


        private DataTable GetSource()
        {
            DataTable table = new DataTable();

            table.Columns.Add(new DataColumn("Id", typeof(string)));
            table.Columns.Add(new DataColumn("RowwNumber", typeof(string)));

            for (int counter = 0; counter < 10; counter++)
            {
                DataRow dr = table.NewRow();
                dr[0] = "Standard " + counter.ToString();
                dr[1] = counter.ToString();

                table.Rows.Add(dr);
            }

            return table;
        }

        public override void DataBind()
        {
            base.DataBind();
        }
    }
}




    

  

   

   



   
